package com.zqr.volatiles;

/**
 * @author zqr
 * @since 2022/11/4
 */
public class CountDemo2 {
    private static int i = 0;

    public static void incr1() {
        i = i + 2;
        System.out.println(Thread.currentThread().getName() + ":" + i);
    }

    public static void incr2() {
        i = i + 5;
        System.out.println(Thread.currentThread().getName() + ":" + i);
    }

    public static void main(String[] args) {
        new Thread(CountDemo2::incr1).start();
        new Thread(CountDemo2::incr2).start();
        System.out.println(i);
    }
}
